 export default class profile_model {
     constructor() {}
     static getShape(shapeName) {
         console.log("step1 ok")

         function circle(radius, startAng, endAng, x_co, y_co) {
             var positions = [];
             var positionsX = [];
             var positionsY = [];
             if (startAng < endAng) {
                 for (var i = startAng; i < endAng; i++) {
                     var radians = Cesium.Math.toRadians(i);
                     var x = radius * Math.cos(radians) + x_co;
                     var y = radius * Math.sin(radians) + y_co;
                     positions.push(
                         [x,
                             y
                         ]
                     );
                 }
             }
             if (endAng < startAng) {
                 for (var j = startAng; j > endAng; j--) {
                     var radians2 = Cesium.Math.toRadians(j);
                     var x2 = radius * Math.cos(radians2) + x_co;
                     var y2 = radius * Math.sin(radians2) + y_co;
                     positions.push(
                         [x2,
                             y2
                         ]
                     );
                 }
             }
             return positions;
         }

         function makeCartesian2(list) {
             var points = [];
             for (var i = 0; i < list.length; i++) {
                 points.push(new Cesium.Cartesian2(list[i][0], list[i][1]));
             }
             return points;
         }

         function convertType(list) {
             var str = [];
             for (var k = 0; k < list.length; k++) {
                 str.push("{'x': '" + list[k][0] + "', 'y': '" + list[k][1] + "'}");
             }
             return str;
         }

         function genPath(pList) {
             let list = [];
             pList.forEach(p => {
                 if (p) {
                     list.push(p.lng);
                     list.push(p.lat);
                     list.push(p.z);
                 }
             });
             return Cesium.Cartesian3.fromDegreesArrayHeights(list);
         }

         function webMercator2LngLat(x, y) { //[12727039.383734727, 3579066.6894065146]
             var lng = x / 20037508.34 * 180;
             var lat = y / 20037508.34 * 180;
             lat = 180 / Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2);
             return [lng, lat]; //[114.32894001591471, 30.58574800385281]
         }

         function adjust(path, x, y, H) {
             let arr = [];
             path.forEach(item => {
                 const obj = {};
                 obj.lng = item.lng + x;
                 obj.lat = item.lat + y;
                 obj.z = item.z + H;
                 arr.push(obj);
             });
             return genPath(arr);
         }
         if (shapeName == "隧道限界") {
             //绘制限界
             var Clearance = [
                 [0, 0],
                 [0, 0.45],
                 [0.75, 0.45],
                 [0.75, 2.95],
                 [0.25, 2.95],
                 [0.25, 4.0],
                 [-0.50, 5.00],
                 [-8.50, 5.00],
                 [-9.0, 4.00],
                 [-9.00, 2.80],
                 [-9.50, 2.80],
                 [-9.50, 0.30],
                 [-8.75, 0.30],
                 [-8.75, 0],
             ];

             return Clearance
         } else if (shapeName == "隧道内轮廓") {
             //中间部位角度  
             var a = (255 + 285) / 2;
             var b = a - 14;
             var c = a + 14;
             //绘制内轮廓
             var positions1 = circle(5.5, -18, 198, 0, 0);
             var positions2 = circle(1.2, 198, 255, -4.08, -1.35);
             var positions3 = circle(18.0, b, c, 0, 14.95);
             var positions4 = circle(1.2, 285, 342, 4.08, -1.35);
             var innerShape = positions1.concat(positions2, positions3, positions4);

             return innerShape
         } else if (shapeName == "隧道初支护") {
             //中间部位角度  
             var a = (255 + 285) / 2;
             var b = a - 14;
             var c = a + 14;
             //初支护
             var ChuZhiHu1 = circle(6.0, -5, 180, 0, 0);
             var ChuZhiHuXia1 = circle(6.0, 180, 198, 0, 0);
             var ChuZhiHuXia2 = circle(1.7, 198, 255, -4.08, -1.35);
             var ChuZhiHuXia3 = circle(18.5, b, c, 0, 14.95);
             var ChuZhiHuXia4 = circle(1.7, 285, 345, 4.08, -1.35);
             var ChuZhiHuXia5 = circle(6.0, 345, 360, 0, 0);
             var ChuZhiHuXia6 = circle(9.75, 360, 342, -3.5, 0);
             var ChuZhiHuXia7 = circle(18.75, c, b, 0, 14.95);
             var ChuZhiHuXia8 = circle(9.75, 198, 180, 3.5, 0);
             var ChuZhiHu2 = circle(6.25, 180, -5, 0, 0);

             var ChuZhiHuShape = ChuZhiHu1.concat(ChuZhiHuXia1, ChuZhiHuXia2, ChuZhiHuXia3, ChuZhiHuXia4, ChuZhiHuXia5, ChuZhiHuXia6, ChuZhiHuXia7, ChuZhiHuXia8, ChuZhiHu2);
             return ChuZhiHuShape
         } else if (shapeName == "隧道二衬") {
             //中间部位角度  
             var a = (255 + 285) / 2;
             var b = a - 14;
             var c = a + 14;
             //绘制二衬
             var lining1 = circle(5.5, -18, 198, 0, 0);
             var YangGong1 = circle(1.2, 198, 255, -4.08, -1.35);
             var YangGong2 = circle(18.0, b, c, 0, 14.95);
             var YangGong3 = circle(1.2, 285, 345, 4.08, -1.35);
             var YangGong4 = circle(1.7, 350, 285, 4.08, -1.35);
             var YangGong5 = circle(18.5, c, b, 0, 14.95);
             var YangGong6 = circle(1.7, 255, 198, -4.08, -1.35);
             var lining2 = circle(6.0, 198, -20, 0, 0);

             var liningShape = lining1.concat(YangGong1, YangGong2, YangGong3, YangGong4, YangGong5, YangGong6, lining2);
             return liningShape
         } else if (shapeName == "隧道路面") {
             //路面
             var HuiTian2 = circle(18.0, b, c, 0, 14.95);
             var HuiTian1 = [
                 [HuiTian2[HuiTian2.length - 1][0], HuiTian2[HuiTian2.length - 1][1] + 3],
                 [HuiTian2[0][0], HuiTian2[0][1] + 2]
             ];
             var LuMian = [
                 HuiTian1[0],
                 HuiTian1[1],
                 [HuiTian1[1][0], HuiTian1[1][1] + 0.35],
                 [HuiTian1[0][0], HuiTian1[0][1] + 0.35]
             ];
             return LuMian
         } else if (shapeName == "隧道回填") {
             //路面下面,仰拱回填
             var HuiTian2 = circle(18.0, b, c, 0, 14.95);
             var HuiTian1 = [
                 [HuiTian2[HuiTian2.length - 1][0], HuiTian2[HuiTian2.length - 1][1] + 3],
                 [HuiTian2[0][0], HuiTian2[0][1] + 2]
             ];
             var HuiTian = HuiTian1.concat(HuiTian2);

             return HuiTian
         } else if (shapeName == "隧道排水沟") {
             //排水沟和电缆沟
             var PaiShuiGou1 = circle(1.2, 175, 260, -4.08, -1.35);
             var LastPX = PaiShuiGou1[PaiShuiGou1.length - 1][0];
             var LastPY = PaiShuiGou1[PaiShuiGou1.length - 1][1];
             console.log(LastPX, LastPY);
             var PaiShuiGou2 = [
                 [LastPX, LastPY],
                 [LastPX, LastPY + 7.8],
                 [LastPX - 0.5, LastPY + 7.8],
                 [LastPX - 0.5, LastPY + 7.8 - 5.2],
                 [LastPX - 0.6 - 3, LastPY + 7.8 - 5.2],
                 [LastPX - 0.6 - 3, LastPY + 7.8],
                 [LastPX - 0.5 - 3 - 0.5, LastPY + 7.8],
                 [LastPX - 0.5 - 3 - 0.5, LastPY + 7.8 + 5],
                 [LastPX - 0.5 - 3 - 0.5 - 0.5, LastPY + 7.8 + 5],
                 [LastPX - 0.5 - 3 - 0.5 - 0.5, LastPY + 7.8 + 5 - 1],
                 [LastPX - 0.5 - 3 - 0.5 - 0.5 - 0.5, LastPY + 7.8 + 5 - 1],
                 [LastPX - 0.5 - 3 - 0.5 - 0.5 - 0.5, LastPY + 7.8 + 5 - 1 - 5],
                 [LastPX - 0.5 - 3 - 0.5 - 0.5 - 0.5 - 2, LastPY + 7.8 + 5 - 1 - 5],
                 [LastPX - 0.5 - 3 - 0.5 - 0.5 - 0.5 - 2, LastPY + 7.8 + 5 - 1 - 5 + 5],
                 [LastPX - 0.5 - 3 - 0.5 - 0.5 - 0.5 - 2 - 0.5, LastPY + 7.8 + 5 - 1 - 5 + 5],
                 [LastPX - 0.5 - 3 - 0.5 - 0.5 - 0.5 - 2 - 0.5, LastPY + 7.8 + 5 - 1 - 5 + 5 + 1]
             ];
             var PaiShuiGou = PaiShuiGou1.concat(PaiShuiGou2);


             //排水沟和电缆沟
             var PaiShuiGouR1 = circle(12, 5, -80, 40.8, -13.5);
             LastPX = PaiShuiGouR1[PaiShuiGouR1.length - 1][0];
             LastPY = PaiShuiGouR1[PaiShuiGouR1.length - 1][1];
             console.log(LastPX, LastPY);
             var PaiShuiGouR2 = [
                 [LastPX, LastPY],
                 [LastPX, LastPY + 7.8],
                 [LastPX + 0.5, LastPY + 7.8],
                 [LastPX + 0.5, LastPY + 7.8 - 5.2],
                 [LastPX + 0.6 + 3, LastPY + 7.8 - 5.2],
                 [LastPX + 0.6 + 3, LastPY + 7.8],
                 [LastPX + 0.5 + 3 + 0.5, LastPY + 7.8],
                 [LastPX + 0.5 + 3 + 0.5, LastPY + 7.8 + 5],
                 [LastPX + 0.5 + 3 + 0.5 + 0.5, LastPY + 7.8 + 5],
                 [LastPX + 0.5 + 3 + 0.5 + 0.5, LastPY + 7.8 + 5 - 1],
                 [LastPX + 0.5 + 3 + 0.5 + 0.5 + 0.5, LastPY + 7.8 + 5 - 1],
                 [LastPX + 0.5 + 3 + 0.5 + 0.5 + 0.5, LastPY + 7.8 + 5 - 1 - 5],
                 [LastPX + 0.5 + 3 + 0.5 + 0.5 + 0.5 + 2, LastPY + 7.8 + 5 - 1 - 5],
                 [LastPX + 0.5 + 3 + 0.5 + 0.5 + 0.5 + 2, LastPY + 7.8 + 5 - 1 - 5 + 5],
                 [LastPX + 0.5 + 3 + 0.5 + 0.5 + 0.5 + 2 + 0.5, LastPY + 7.8 + 5 - 1 - 5 + 5],
                 [LastPX + 0.5 + 3 + 0.5 + 0.5 + 0.5 + 2 + 0.5, LastPY + 7.8 + 5 - 1 - 5 + 5 + 1]
             ];
             var PaiShuiGouR = PaiShuiGouR1.concat(PaiShuiGouR2);

         }
     }
 }